package controller.converters;

import java.util.Locale;
import java.util.ResourceBundle;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;


public class LanguageConverter  implements Converter  {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value)
    {
            return value;
    }

    @Override
      public String getAsString(FacesContext context, UIComponent component, Object value)
      {
        Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
        ResourceBundle bundle = ResourceBundle.getBundle(FacesContext.getCurrentInstance().getApplication().getMessageBundle(), locale);
        return bundle.getString((String) value);

    }

}
